package api

import (
	"go_web/common"
	"go_web/service"
	"net/http"
)

func (a *Api) Login(w http.ResponseWriter, r *http.Request) {

	//接收用户名和密码

	params := common.GetRequestJSONParam(r)
	//断言
	username := params["username"].(string)
	passwd := params["passwd"].(string)

	loginRes, err := service.Login(username, passwd)
	if err != nil {
		common.Error(w, err)
	}
	common.Success(w, loginRes)
}
